package com.zbj.storm.kafka;

import org.apache.storm.spout.Scheme;
import org.apache.storm.tuple.Fields;
import org.apache.storm.tuple.Values;

import java.nio.ByteBuffer;
import java.util.List;

/**
 * com.zbj.storm.kafka.MessageScheme
 *
 * @author weigang
 * @create 2019-09-18
 **/
public class MessageScheme implements Scheme {

    @Override
    public List<Object> deserialize(ByteBuffer ser) {
        try {
            String msg = ser.toString();
            return new Values(msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Fields getOutputFields() {
        return new Fields("msg");
    }
}